/**
 * @file 用于存储所有的mutations
 * 定义为原子操作，即最基本的操作，不可再分
 */
import types from './types'

export default {
  // 菜单位置相关信息
  [types.HAP_FILE_MENU_STATE] (state, status) {
    state.menuState = {...state.menuState, ...status}
  },
  // 文件状态相关
  [types.HAP_FILE_SELECTED_FILE] (state, file) {
    state.selectedFile = file
  },
  // toast相关
  [types.HAP_TOAST_ADD] (state, { type = 'DANGER', title = '', message = '', timeoutId } = {}) {
    state.toasts.unshift({
      type,
      title,
      message,
      timeoutId
    })
  },
  [types.HAP_TOAST_REMOVE] (state, index) {
    state.toasts.splice(index, 1)
  },
  [types.HAP_TOAST_FINISH] (state) {
    state.toasts.pop()
  },
  [types.HAP_TERMINAL_INFO_STATUS] (state, info) {
    state.terminalInfo = info
  }
}
